home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wmtest.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  66 lines

  1. ; $Id: wmtest.pro,v 1.4 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple non-exclusive menu widget.
  7. ; The menu contains a list of colors.  When a button is
  8. ; pushed in (selected), the message, "Color selected." 
  9. ; is printed in the IDL window.  When a button that has
  10. ; been previously pushed in is de-selected, the message
  11. ; "Color de-selected." is printed in the IDL window.
  12.  
  13. ; Non-exclusive menus are lists of buttons in which any
  14. ; number of buttons can be selected at the same time.
  15.  
  16. ; For an example of an exclusive menu, see the routine
  17. ; WEXCLUS.PRO.
  18.  
  19.  
  20.  
  21.  
  22. PRO wmtest_event, event
  23. ; This procedure is the event handler for a non-exclusive menu widget.
  24.  
  25. ; Use event.value to get the VALUE of any action:
  26.  
  27. ; When a widget event occurs, an event structure is returned.
  28. ; Part of that structure is a 'select' field that is equal to 
  29. ; 1 if a button was selected or 0 if the button was de-selected.
  30. ; For Menu items, any VALUE returned will be the text of the menu item.
  31. ; Therefore, we can just print out the words as they are selected.
  32.  
  33. IF (event.select EQ 1) THEN PRINT, event.value, ' selected.' $
  34. ELSE PRINT, event.value, ' de-selected.'
  35.  
  36. END
  37.  
  38.  
  39.  
  40. PRO wmtest, GROUP = GROUP
  41. ; This procedure creates a non-exclusive menu widget.
  42.  
  43. ; Make the top-level base widget:
  44.  
  45. base = WIDGET_BASE(TITLE = 'Non-Exclusive Menu Example', /COLUMN, XSIZE = 300)
  46.  
  47. ; Make 'items' a 1-dimensional text array containing the menu items:
  48.  
  49. items = ['Red','Orange','Yellow','Green','Blue','Indigo','Violet']
  50.  
  51. ; The CW_BGROUP procedure will automatically create the menu items for us.
  52. ; We only have to give it the menu item labels (in the array 'items')
  53. ; and, optionally, the base to which the menu belongs (here we use 'base',
  54. ; the top-level base widget).  The /NONEXCLUSIVE keyword makes the 
  55. ; menu non-exclusive:
  56.  
  57. menu = CW_BGROUP(base, items, /NONEXCLUSIVE, IDS = buttons, /RETURN_NAME)
  58.  
  59. ; Realize the widgets:
  60. WIDGET_CONTROL, base, /REALIZE
  61.  
  62. ; Hand off to the XMANAGER:
  63. XMANAGER, 'wmtest', base, GROUP_LEADER = GROUP, /NO_BLOCK
  64.  
  65. END
  66.